// 用户相关
export interface ILoginParams {
  nickName: string
  password: string
}
export enum UserRole {
  ADMIN = 1,
  USER = 2
}
export enum AccountStatus {
  OPEN = 1,
  CLOSED = 2
}
export interface ILoginData {
  token: string
  user_id: number
  user_role: UserRole //用户角色，1：管理员  2：普通用户
}
export const userRoleMap: Record<UserRole, string> = {
  [UserRole.ADMIN]: '管理员',
  [UserRole.USER]: '用户'
}

export interface IUser {
  user_id: number
  nick_name: string
  user_role: UserRole
  is_active: AccountStatus
  file_num: number
  query_num: number
  login_time: number
}

export interface IAddUserParmas {
  nick_name: string
  password: string
}
export interface IEditUserParams {
  user_id: number
  nick_name?: string // 默认传空不修改
  password?: string // 默认传空不修改
  is_active: AccountStatus
}

export interface IUserApi {
  login: (params: ILoginParams) => Promise<ILoginData>
  getUsersList: () => Promise<IUser[]>
  addUser: (params: IAddUserParmas) => Promise<void>
  editUser: (params: IEditUserParams) => Promise<void>
  deleteUser: (params: { id: number }) => Promise<void>
  logout: () => Promise<void>
}
